import java.util.Arrays;

public class Solution_0221 {
    public static int removeElement(int[] nums, int val) {
        int len = nums.length;
        int n = 0;
        for (int i = 0; i < len; i++) {
            if(nums[i] != val) {
                nums[n] = nums[i];
                n++;
            }
        }
        return n;
    }

    public static void main(String[] args) {
        int[] arr = {0,1,2,2,3,0,4,2};
        System.out.println(removeElement(arr, 2));
    }
}
